﻿var Ajax = (function () {
    var result = {};

    this.layout = "center";
    function Error(message) {
        noty({ layout: layout, type: "error", message: message });
    }
    function Success(message) {
        noty({ layout: layout, type: "success", message: message });
    }

    result.init = function (layout) {
        this.layout = layout;
    }

    result.post = function (url,data,su,er) {
        $.ajax({
            url: url,
            type:"post",
            contentType: "application/json; charset=utf-8",
            data: data,
            dataType: "json",
            success: function (data) {
                su(data);
            },error:function(error){
                er(error);
            }
        })
    }
    result.get = function (url,su,er) {
        $.ajax({
            url: url,
            type:"get",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data) {
                su(data);
            }, error: function (error) {
                er(error);
            }
        })
    }
    return result;
})()